<template>
  <div id="app">
    <!-- 导航栏 -->
    <header class="navbar">
      <div class="container">
        <div class="navbar-content">
          <!-- Logo -->
          <div class="navbar-brand">
            <RouterLink to="/" class="brand-link">
              <el-icon size="32" color="#0071E3"><Shop /></el-icon>
              <span class="brand-text">壹周货源平台</span>
            </RouterLink>
          </div>

          <!-- 导航菜单 -->
          <nav class="navbar-nav">
            <RouterLink to="/" class="nav-link">首页</RouterLink>
            <RouterLink to="/merchants" class="nav-link">商家展示</RouterLink>
            <RouterLink to="/contact" class="nav-link">入驻联系</RouterLink>
            <RouterLink to="/about" class="nav-link">关于我们</RouterLink>
          </nav>

          <!-- 移动端菜单按钮 -->
          <div class="mobile-menu-btn" @click="toggleMobileMenu">
            <el-icon size="24"><Menu /></el-icon>
          </div>
        </div>

        <!-- 移动端菜单 -->
        <div class="mobile-menu" :class="{ active: mobileMenuActive }">
          <RouterLink to="/" class="mobile-nav-link" @click="closeMobileMenu">首页</RouterLink>
          <RouterLink to="/merchants" class="mobile-nav-link" @click="closeMobileMenu">商家展示</RouterLink>
          <RouterLink to="/contact" class="mobile-nav-link" @click="closeMobileMenu">入驻联系</RouterLink>
          <RouterLink to="/about" class="mobile-nav-link" @click="closeMobileMenu">关于我们</RouterLink>
        </div>
      </div>
    </header>

    <!-- 主要内容 -->
    <main class="main-content">
      <RouterView />
    </main>

    <!-- 页脚 -->
    <footer class="footer">
      <div class="container">
        <div class="footer-content">
          <div class="footer-section">
            <h3>壹周货源平台</h3>
            <p>连接优质商家，打造时尚供应链生态</p>
          </div>
          <div class="footer-section">
            <h4>快速链接</h4>
            <ul>
              <li><RouterLink to="/merchants">商家展示</RouterLink></li>
              <li><RouterLink to="/contact">入驻联系</RouterLink></li>
              <li><RouterLink to="/about">关于我们</RouterLink></li>
            </ul>
          </div>
          <div class="footer-section">
            <h4>联系我们</h4>
            <p>联系客服微信： HH-188-199</p>
            <p>商务联系方式： 13055317158</p>
          </div>
        </div>
        <div class="footer-bottom">
          <p>&copy; 2024 壹周货源平台. All rights reserved.</p>
        </div>
      </div>
    </footer>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { RouterLink, RouterView } from 'vue-router'
import { Shop, Menu } from '@element-plus/icons-vue'

const mobileMenuActive = ref(false)

const toggleMobileMenu = () => {
  mobileMenuActive.value = !mobileMenuActive.value
}

const closeMobileMenu = () => {
  mobileMenuActive.value = false
}
</script>

<style scoped>
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 导航栏 */
.navbar {
  background: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.navbar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
}

.navbar-brand {
  display: flex;
  align-items: center;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1.25rem;
}

.brand-text {
  color: var(--text-primary);
}

.navbar-nav {
  display: flex;
  gap: 40px;
  align-items: center;
}

.nav-link {
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 1rem;
  transition: color 0.3s ease;
  position: relative;
}

.nav-link:hover {
  color: var(--primary-color);
}

.nav-link.router-link-active {
  color: var(--primary-color);
}

.nav-link.router-link-active::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary-color);
  border-radius: 1px;
}

.mobile-menu-btn {
  display: none;
  cursor: pointer;
  color: var(--text-primary);
}

.mobile-menu {
  display: none;
  flex-direction: column;
  background: white;
  border-top: 1px solid var(--border-color);
  padding: 20px 0;
}

.mobile-menu.active {
  display: flex;
}

.mobile-nav-link {
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
  transition: color 0.3s ease;
}

.mobile-nav-link:hover,
.mobile-nav-link.router-link-active {
  color: var(--primary-color);
}

/* 主要内容 */
.main-content {
  flex: 1;
}

/* 页脚 */
.footer {
  background: var(--secondary-color);
  color: white;
  padding: 60px 0 20px;
  margin-top: auto;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 40px;
  margin-bottom: 40px;
}

.footer-section h3,
.footer-section h4 {
  color: white;
  margin-bottom: 20px;
  font-weight: 600;
}

.footer-section h3 {
  font-size: 1.5rem;
}

.footer-section h4 {
  font-size: 1.125rem;
}

.footer-section p {
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.6;
  margin-bottom: 10px;
}

.footer-section ul {
  list-style: none;
  padding: 0;
}

.footer-section ul li {
  margin-bottom: 10px;
}

.footer-section ul li a {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer-section ul li a:hover {
  color: white;
}

.footer-bottom {
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.footer-bottom p {
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .navbar-nav {
    display: none;
  }

  .mobile-menu-btn {
    display: block;
  }

  .footer-content {
    grid-template-columns: 1fr;
    gap: 30px;
    text-align: center;
  }
}
</style>
